------------------ fgui require start ------------------
------------------  fgui require end  ------------------
local Listdetails2Skin = Class("Listdetails2Skin");

function Listdetails2Skin:ctor(com)
    ------------------ fgui事件绑定start ------------------
    self:bindChild(com);
    self.state.onChanged:Add(self.onChange_state,self);
    self.btn_head.onClick:Add(self.onTouch_btn_head,self);
    self.btn_ok.onClick:Add(self.onTouch_Btn_ok,self);
    self.btn_cancel.onClick:Add(self.onTouch_Btn_cancel,self);
    self:init();
    ------------------  fgui事件绑定end  ------------------
end

function Listdetails2Skin:bindChild(com)
    ------------------ fgui变量绑定start ------------------
    self.fguiObj = com;
    self.state = com:GetController("state");
    self.btn_head = com:GetChild("btn_head");
    self.btn_ok = com:GetChild("Btn_ok");
    self.btn_cancel = com:GetChild("Btn_cancel");
    self.text_lvName = com:GetChild("Text_lvName");
    self.text_lv = com:GetChild("Text_lv");
    self.text_playerName = com:GetChild("Text_playerName");
    self.text_power = com:GetChild("Text_power");
    self.text_online = com:GetChild("Text_online");
    ------------------  fgui变量绑定end  ------------------
    self.frame =  self.btn_head:GetChild("frame");
    self.icon =  self.btn_head:GetChild("head"):GetChild("HeadIcon");
end

function Listdetails2Skin:init()
    self.data = nil;
end

function Listdetails2Skin:OnDestroy()
    ------------------ fgui事件移除start ------------------
    self:beforeDestroy();
    self.state.onChanged:Clear();
    self.btn_head.onClick:Clear();
    self.btn_ok.onClick:Clear();
    self.btn_cancel.onClick:Clear();
    ------------------  fgui事件移除end  ------------------
end

function Listdetails2Skin:onChange_state(event) end

function Listdetails2Skin:onTouch_Btn_ok(obj)
    EventContext.StopPropagation(obj);
    --if logicMgr.GuildManager.getRemainApplyCnt() <= 0 then
    --    UISysTips.AddMsg(getLanguage("GuildInvestment_1151"));
    --    return;
    --end
    local unionId = logicMgr.GuildManager.getUnionId();
    local isArgee = 1;
    local ids = {self.data.showInfo.playerId};
    unionHandler.reqHandleJoinList(unionId,isArgee,ids);
end

function Listdetails2Skin:onTouch_Btn_cancel(obj)
    EventContext.StopPropagation(obj);
    local unionId = logicMgr.GuildManager.getUnionId();
    local isArgee = 0;
    local ids = {self.data.showInfo.playerId};
    unionHandler.reqHandleJoinList(unionId,isArgee,ids);
end

function Listdetails2Skin:onTouch_btn_head(obj) end

------------------  ↑ fgui事件句柄 ↑  ------------------

function Listdetails2Skin:beforeDestroy() end

function Listdetails2Skin:getPlayerId()
    return self.data.showInfo.playerId;
end

function Listdetails2Skin:onRender(data)
    self.data = data;
    self.text_playerName.text = data.showInfo.name;
    self.text_power.text = getNumString(toNumber(tostring(data.showInfo.maxPower)));
    self.text_lv.text = data.showInfo.level;
    self.frame.url = "ui://ICONAtlas/" .. data.showInfo.picFrame;
    self.icon.url = logicMgr.SkinManager.GetHeroIconBySkinId(data.showInfo.pic)--"ui://ICONAtlas/" .. dataTable.getRow("t_hero",data.showInfo.pic)["f_HeroIcon"]
    self.state.selectedIndex = 0;
    if data.offlineTime then
        local offlineTime = tonumber(tostring(data.offlineTime));
        if offlineTime > 0 then
            self.text_online.text = getLanguage("GuildInvestment_1076") .. getTimeStrType2(offlineTime);
            self.state.selectedIndex = 1;
        else
            self.text_online.text = getLanguage("GuildInvestment_1077");
        end
    else
        self.text_online.text = getLanguage("GuildInvestment_1077");
    end
end

return Listdetails2Skin;
